﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using ZhimeiSoft.Framework.Client.Utils;
using ZhimeiSoft.CharmManager.DOL;
using ZhimeiSoft.CharmManager.Client.Manager;

namespace ZhimeiSoft.CharmManager.Client.Forms.Control.ServiceItem
{
    public partial class SelectServiceItemControl : UserControl
    {
        private int iCustomerID = -1;
        private DataSet dsServiceItem;
        public SelectServiceItemControl()
        {
            InitializeComponent();
        }

        public SelectServiceItemControl(int customerID)
        {
            InitializeComponent();
            this.iCustomerID = customerID;
        }

        private void rbAllServiceItem_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            int iRowHandle = gvServiceItem.FocusedRowHandle;
            if (iRowHandle < 0)
            {
                MsgBox.MsgInfo("请先选择服务项目。");
                return;
            }

            DataRow dr = gvServiceItem.GetDataRow(iRowHandle);

        }

        private void btnClose_Click(object sender, EventArgs e)
        {

        }

        private void rbAll_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void rbCustomer_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void Init()
        {
            string error = string.Empty;
            string sFilter = "";
            bool bFlag = true;
            if (iCustomerID == -1)
            {
                sFilter = string.Format("{0}='{1}'", DBEntityServiceItem.FieldName.STATE, DBEntityServiceItem.ENUM_STATE.C0A);
                bFlag = BussinessProxyManager.Instance.QueryServiceItem(sFilter, out dsServiceItem, out error);
            }
            else
            {
                sFilter = string.Format("{0}={1}", DBEntityCustomerServiceItem.FieldName.CUSTOMERID, iCustomerID.ToString());
                bFlag = BussinessProxyManager.Instance.QueryCustomerServiceItem(sFilter, out dsServiceItem, out error);
            }
            if (bFlag == false)
            {
                MsgBox.MsgInfo(error);
                return;
            }

            this.grdServiceItem.DataSource = null;
            this.grdServiceItem.DataSource = dsServiceItem.Tables[0].DefaultView;
        }

    }
}
